package priotityqeue;

import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.function.IntFunction;

class IntComparator implements Comparator<Integer> {

    @Override
    public int compare(Integer o1, Integer o2) {
        //如果判定o1小于o2，返回-1；如果判定o1大于o2，返回1；如果判定o1等于o2，返回0。
        return o2 - o1;
    }
}

    public class Test2 {
        public static void main(String[] args) {
           // PriorityQueue<Integer> queue = new PriorityQueue<>(new IntComparator());
            PriorityQueue<Integer> queue = new PriorityQueue<>(new Comparator<Integer>() {
                @Override
                public int compare(Integer o1, Integer o2) {
                    return 0;
                }
            });
            queue.add(10);
            queue.add(5);
            queue.add(15);
            queue.add(20);
            queue.add(1);

            System.out.println(queue.poll());
            System.out.println(queue.poll());
            System.out.println(queue.poll());
            System.out.println(queue.poll());
            System.out.println(queue.poll());

        }
    }

